﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using KKCai.SC.App.Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using KKCai.SC.App.DAL;

namespace KKCai.SC.App.Test
{
    [TestFixture]
    public class Tests
    {
        private int MethodName()
        {
            RecordDao dao = new RecordDao();

            RecordInfo r = dao.Order("id", false, 1)[0];

            int last = Convert.ToInt32(r.TermNo.Substring(6));

            return last;
        }

        public string Test()
        {
            string url = "http://trade.aicairen.com/ajax/openterm.aspx?lotType=xysc";
            string resp = new WebUtils().DoGet(url);

            JObject o = JObject.Parse(resp);

            object obj = (object)o.SelectToken("OpenList");

            IList<RecordInfo> list = JsonConvert.DeserializeObject<IList<RecordInfo>>(obj.ToString());

            RecordDao dao = new RecordDao();

            for (int i = list.Count-1; i >= 0; i--)
            {
                dao.Save(list[i]);
            }

            return "";
        }


    }
}
